import threading
from time import sleep

g_num = 1

"""
子线程之间共享全局变量
"""
def test1():
    global g_num
    g_num += 1
    print('test1------%d' % g_num)


def test2():
    print('test2------%d' % g_num)


def main():
    t1 = threading.Thread(target=test1)
    t2 = threading.Thread(target=test2)
    t1.start()
    sleep(1)
    t2.start()
    sleep(1)
    print('main------%d' % g_num)


if __name__ == '__main__':
    main()
